/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package DTO;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Objects;

/**
 *
 * @author Pham
 */
public class DTOProvider {
    int providerId;
    String providerName;
    String providerPhone;
    String providerEmail;
    String providerFax;
    String providerAddress;
    
    //accessor
    public int getProviderId() {
        return providerId;
    }

    public void setProviderId(int providerId) {
        this.providerId = providerId;
    }

    public String getProviderName() {
        return providerName;
    }

    public void setProviderName(String providerName) {
        this.providerName = providerName;
    }

    public String getProviderPhone() {
        return providerPhone;
    }

    public void setProviderPhone(String providerPhone) {
        this.providerPhone = providerPhone;
    }

    public String getProviderEmail() {
        return providerEmail;
    }

    public void setProviderEmail(String providerEmail) {
        this.providerEmail = providerEmail;
    }

    public String getProviderFax() {
        return providerFax;
    }

    public void setProviderFax(String providerFax) {
        this.providerFax = providerFax;
    }

    public String getProviderAddress() {
        return providerAddress;
    }

    public void setProviderAddress(String providerAddress) {
        this.providerAddress = providerAddress;
    }
    
    //contructor
    public DTOProvider() {
    }

    public DTOProvider(int providerId, String providerName, String providerPhone, String providerEmail, String providerFax, String providerAddress) {
        this.providerId = providerId;
        this.providerName = providerName;
        this.providerPhone = providerPhone;
        this.providerEmail = providerEmail;
        this.providerFax = providerFax;
        this.providerAddress = providerAddress;
    }
    
    public DTOProvider(ResultSet rs) throws SQLException
    {
        this.providerId = rs.getInt("provider_id");
        this.providerName = rs.getString("provider_name");
        this.providerPhone = rs.getString("provider_phonenumber");
        this.providerEmail = rs.getString("provider_email");
        this.providerFax = rs.getString("provider_fax");
        this.providerAddress = rs.getString("provider_address");
    }
    
    @Override
    public String toString()
    {
        return providerName;
    }
    
    @Override
    public boolean equals(Object obj)
    {
        if(obj instanceof DTOProvider)
        {
            DTOProvider dtoProvider = (DTOProvider)obj;
            return dtoProvider.providerName.equals(this.providerName);
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + Objects.hashCode(this.providerName);
        return hash;
    }
}
